package cn.stylefeng.guns.weixin.banner;

import cn.stylefeng.guns.modular.banner.pojo.request.BannerRequest;
import cn.stylefeng.guns.modular.banner.service.BannerService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * banner控制器
 *
 * @author wxz
 * @date 2022/01/11 11:53
 */
@RestController
@ApiResource(name = "banner")
public class BannerWxController {

    @Resource
    private BannerService bannerService;


    /**
     * 查看详情
     *
     * @author wxz
     * @date 2022/01/11 11:53
     */
    @GetResource(name = "查看详情", path = "/wx/banner/detail", requiredPermission = false, requiredLogin = false)
    public ResponseData detail(@Validated(BannerRequest.detail.class) BannerRequest bannerRequest) {
        bannerRequest.setStatus(1);
        return new SuccessResponseData(bannerService.detail(bannerRequest));
    }

    /**
     * 获取列表
     *
     * @author wxz
     * @date 2022/01/11 11:53
     */
    @GetResource(name = "获取列表", path = "/wx/banner/list", requiredPermission = false, requiredLogin = false)
    public ResponseData list(BannerRequest bannerRequest) {
        bannerRequest.setStatus(1);
        return new SuccessResponseData(bannerService.findList(bannerRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author wxz
     * @date 2022/01/11 11:53
     */
    @GetResource(name = "分页查询", path = "/wx/banner/page", requiredPermission = false, requiredLogin = false)
    public ResponseData page(BannerRequest bannerRequest) {
        bannerRequest.setStatus(1);
        return new SuccessResponseData(bannerService.findPage(bannerRequest));
    }



}